Yacon.security = {
	
	encryptByDES : function(message, key) {
		
	    var keyHex = CryptoJS.enc.Utf8.parse(key);
	    
	    message = message + Yacon.security.randomKey(4);
	    
	    var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
	        mode: CryptoJS.mode.ECB,
	        padding: CryptoJS.pad.Pkcs7
	    });
	    
	    var retMsg = encrypted.toString();
	    
	    return retMsg.substring(0,1) + key + retMsg.substring(1);
	    
	},
	
	randomKey : function(bit){
		
		var str = "ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";		
		var len = str.length;		
		
		var randK = "";
		
		for(var i=0;i<bit;i++){
			
			var rand = parseInt(Math.random()*100);
		
			var index = rand % len;		
			
			randK += str.charAt(index);			
		}
		
		return randK;
		
	},
	
	eds : function(message){
		
		return Yacon.security.encryptByDES(message, Yacon.security.randomKey(8));
		
	}
	
}